<template>
  <j-select-biz-component :width="multiple?1000:800" v-bind="configs" v-on="$listeners"/>
</template>

<script>
import JSelectBizComponent from './JSelectBizComponent'

export default {
  name: 'JSelectProduct',
  components: { JSelectBizComponent },
  props: {
    value: {
      type: String,
      default: ''
    },
    name: {
      type: String,
      default: '商品'
    },
    selectButtonText: {
      type: String,
      default: '选择'
    },
    inputs: {
      type: Boolean,
      default: true
    },
    searchIcon: {
      type: String,
      default: 'search'
    },
    queryConfig: {
      type: Array,
      default: () => [
        {
          label: '商品编号',
          key: 'goodsCode'
        },
      ]
    },
    listUrl: {
      type: String,
      default: '/goods/cnGoods/findPageList',
    },
    multiple: {
      type: Boolean,
      default: true
    },
    buttons: {
      type: Boolean,
      default: true
    },
    returnName: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      settings: {
        displayKey: 'goodsName',
        returnKeys: ['id', 'goodsCode'],
        queryParamCode: 'goodsName',
        queryParamText: '商品名称',
        ellipsisLength: -1,
        columns: [
          { title: '商品名称', field: 'goodsName',  widthRight: '70%' },
          { title: '商品编号', field: 'goodsCode',  },
        ]
      }
    }
  },
  computed: {
    configs() {
      return Object.assign({
        value: this.value,
        returnName: this.returnName,
        buttons: this.buttons,
        inputs:this.inputs,
        listUrl: this.listUrl,
        searchIcon:this.searchIcon,
        multiple: this.multiple,
        name:this.name,
        selectButtonText:this.selectButtonText
      }, this.settings, this.$attrs)
    }
  }
}
</script>

<style lang="less" scoped></style>